package com.CusterRelSys.control;

import com.CusterRelSys.entity.VOrders;
import com.CusterRelSys.entity.VProuduct;
import com.CusterRelSys.service.VOrdersLineMapperServiceNY;
import com.CusterRelSys.service.VOrdersMapperServiceNY;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by Administrator on 2017/12/1.
 */
@Controller
@RequestMapping("/VOrder")
public class VOrdersControlNY {
    @Autowired
    private VOrdersMapperServiceNY vOrdersMapperServiceNY;

    @Autowired
    private VOrdersLineMapperServiceNY vOrdersLineMapperServiceNY;

    @RequestMapping("/findVOrdersByOdrCustNo")
    public @ResponseBody List<VOrders> findVOrdersByOdrCustNo(String odrCustNo){
        List<VOrders> vOrdersList = vOrdersMapperServiceNY.findVOrdersByOdrCustNo(odrCustNo);
        for (VOrders vOrders : vOrdersList) {
            System.out.println(vOrders);
        }
        return vOrdersList;
    }

    @RequestMapping("/findVProductByOddOrderId")
    public @ResponseBody List<VProuduct> findVProductByOddOrderId(String oddOrderId){
        System.out.println(oddOrderId);
        List<VProuduct> vProuductList=new ArrayList<>();
        List<Integer> integerList = vOrdersLineMapperServiceNY.findVOrdersLineByOddOrderId(oddOrderId);
        for (Integer integer : integerList) {
            System.out.println(integer);
            VProuduct vProuduct = vOrdersLineMapperServiceNY.findProductByProdId(integer);
            vProuductList.add(vProuduct);
        }
        for (VProuduct vProuduct : vProuductList) {
            System.out.println(vProuduct);
        }
        return vProuductList;
    }
}
